package com.test.simplechat;

import com.test.simplechat.server.NettyChatServer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;

import javax.annotation.PostConstruct;

/**
 * @author wen
 * 启动类
 */
@SpringBootApplication
@ServletComponentScan
public class SimplechatApplication {
    private static String wsPort;
    private static String wsPath;
    public static void main(String[] args) {

        SpringApplication application = new SpringApplication(SimplechatApplication.class);
//        application.addListeners(new ServerConfig());
        application.run(args);
        try {
            new NettyChatServer(Integer.valueOf(wsPort), wsPath).start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String getWsPort() {
        return wsPort;
    }

    @Value("${ws.port}")
    public void setWsPort(String wsPort) {
        SimplechatApplication.wsPort = wsPort;
    }

    public String getWsPath() {
        return wsPath;
    }

    @Value("${ws.path}")
    public void setWsPath(String wsPath) {
        SimplechatApplication.wsPath = wsPath;
    }


}
